<template>
    <div class="sidebar">
        <template v-for="item in items">
            <router-link :to="item.path" v-if="item.path">
                <el-menu-item v-if="item.children ==null || item.children.length === 0" :index="item.path">
                    <i :class="item.icon" style="color: #FFF"></i>
                    <span>{{item.name}}</span>
                </el-menu-item>
            </router-link>
            <!-- 判断是否有二级路由 -->
            <el-submenu v-if="item.children" :index="item.path">
                <template slot="title">
                    <i :class="item.icon" style="color: #FFF"></i>
                    <span>{{item.name}}</span>
                </template>
                <!--递归组件，把遍历的值传回子组件，完成递归调用-->
                <Menu :items="item.children"/>
            </el-submenu>
        </template>
    </div>
</template>

<script>
    export default {
        name: "Menu",
        props: {
            items: Array,
        },
        data() {
            return {
                collapse: false,
            };
        }
    };
</script>
<style>
    .el-menu-item.is-active {
        background: #2F73F8 !important;
    }

    .el-menu-item:hover {
        background: #2F73F8 !important;
    }

    .menu_page {
        position: fixed;
        top: 71px;
        left: 0;
        min-height: 100%;
        height: 100vh;
        z-index: 99;
    }

    .sidebar::-webkit-scrollbar {
        width: 0;
    }

    .sidebar-el-menu:not(.el-menu--collapse) {
        width: 250px;
    }

    .el-menu {
        border: none;
    }

    .fa-margin {
        margin-right: 5px;
    }

    .el-menu-vertical-demo:not(.el-menu--collapse) {
        width: 180px;
    }

    .admin-el-menu {
        width: 64px;
    }

    .el-submenu .el-menu-item {
        min-width: 180px;
    }

    .hiddenDropdown,
    .hiddenDropname {
        display: none;
    }

    i.el-submenu__icon-arrow.el-icon-arrow-right {
        display: none !important;
    }

    a {
        color: #ccc;
        text-decoration: none;
    }

    a:hover {
        text-decoration: none;
    }
</style>
